home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softdisk Supreme
/
Softdisk Supreme.iso
/
pc
/
DSK Files
/
0-49
/
SD011a.dsk
/
BASICALC IN APPLESOFT.bas
< prev
next >
Wrap
BASIC Source File
|
2003-06-12
|
12KB
|
394 lines
1 REM CHANGES IN:
2 REM 2104, 2109, 2256
3 REM 1110, 6240, 660,
4 REM 265, 240, 2905
5 REM 640, 641
6 REM 7/30/82
10 REM **************************
11 REM * *
12 REM * ELECTRONIC WORKSHEET *
13 REM * *
14 REM * COPYRIGHT (C) 1982 *
15 REM * WILLIAM V R SMITH *
16 REM * *
17 REM **************************
18 REM
19 CLEAR : DIM A$(70,10),B$(70,10),CW(12),IV(50)
20 SY = 1:XM = 1:YM = 1:SX = 1
30 FOR X = 1 TO 12:CW(X) = 9: NEXT X
35 S$ = " "
37 T$ = "ABCDEFGHIJKLMNO"
38 T1$ = "*********************"
99 GOTO 2000
100 REM *******************
101 REM * VARABLE PARCER *
102 REM *******************
103 L = LEN(A$(Y,X)):F = 2:A1 = 0:A2 = 0:P = 1:H$ = "":OF = 1
105 IF L = 0 THEN 400
110 IF P >L THEN 400
115 GOSUB 500
130 IF C >64 THEN GOSUB 450: IF P >L THEN RETURN
135 IF C = 46 THEN 170
140 IF C >41 AND C <48 THEN GOSUB 200:F = C -41: GOTO 110
150 IF C = 38 THEN 700
160 IF C >47 AND C <58 THEN 170
162 IF C = 58 THEN 900
165 GOTO 400
170 H$ = H$ + CHR$(C): IF P >L THEN GOSUB 200: GOTO 600
180 GOSUB 500: GOTO 130
200 A2 = VAL(H$):H$ = "": GOSUB 300: REM FUNCTION
210 RETURN
220 REM * INPUT STATEMENT **
225 IV = 1:I$ = "": GOTO 235
230 IF LEN(I$) = 0 THEN A$ = "": RETURN
235 GET A$
240 IF A$ = CHR$(8) THEN L = LEN(I$):I$ = MID$ (" " +I$,2,L -1): VTAB 2: HTAB 1: PRINT I$;: CALL -868: GOTO 230
245 IF A$ = CHR$(21) THEN 275
250 IF A$ = CHR$(13) THEN 280
255 IF ASC(A$) <31 THEN 235
256 IF A$ = CHR$(34) THEN 235
260 I$ = I$ +A$
265 VTAB 2: HTAB 1: PRINT I$;
270 IV = IV +1: GOTO 235
275 A$ = MID$ (A$(Y,X),IV,1): GOTO 260
280 IF IV = 1 THEN A$ = "": RETURN
285 A$ = I$: RETURN
300 REM *********************
301 REM *
302 REM * PERFORM MATH FUNCTION
303 REM *
304 REM *********************
305 F1 = F:F = 2
310 ON F1 GOSUB 330,340,320,350,320,370
320 RETURN
330 A1 = A1 *A2: RETURN
340 A1 = A1 +A2: RETURN
350 A1 = A1 -A2: RETURN
370 IF A2 < >0 THEN A1 = A1/A2
380 RETURN
399 END
400 H$ = MID$ (A$(Y,X),1,L) +" "
405 H$ = LEFT$(H$,CW(X))
406 IF H$ = B$(Y,X) THEN RETURN
407 B$(Y,X) = H$
409 GOSUB 680: REM * XM AND YM TEST
410 RETURN
440 REM *****************
441 REM *
442 REM * FIND MATH VALUE
443 REM * OF SCREEN
444 REM *****************
450 X3 = C -64
451 IF X3 >15 THEN GOSUB 400: RETURN
452 H$ = "": IF L = 1 THEN 400
453 GOSUB 500: IF C <48 OR C >57 THEN GOTO 400
454 GOTO 460
455 GOSUB 500
460 IF C <48 OR C >57 THEN 470
465 H$ = H$ + CHR$(C)
466 IF P >L THEN 470
467 GOTO 455
470 Y3 = VAL(H$)
475 IF Y3 >70 OR X3 >15 THEN H$ = "ERROR":P = L +1: GOTO 620
480 H$ = B$(Y3,X3)
485 GOSUB 200
490 IF P >L THEN GOSUB 600: RETURN
495 RETURN
500 REM *** PARCE LINE FOR CHAR
510 C = ASC( MID$ (A$(Y,X),P,1)):P = P +1
520 RETURN
600 REM *******************
601 REM *
602 REM * ASSIGN ANSWER
603 REM *
604 REM *******************
610 IF A$(Y,X) = "" THEN RETURN
615 IF LEN( STR$( INT(A1))) >CW(X) THEN H$ = "ERROR"
620 ON OF GOSUB 640,650,660,670
625 IF OF = 4 OR OF = 1 THEN 675
630 B$(Y,X) = RIGHT$(" " + STR$(A1),CW(X))
635 GOTO 675
640 SF$ = "": IF A1 <0 THEN SF$ = "-"
641 WA = ABS(A1):A3 = INT(WA):A1 = (WA -A3) +1.001:H$ = SF$ + STR$(A3) +"." + MID$ ( STR$(A1),3,2)
645 B$(Y,X) = RIGHT$(S$ +H$,CW(X)): RETURN
650 A1 = INT(A1): RETURN
660 FL$ = STR$(A1):A1 = VAL( LEFT$(FL$,CW(X))): RETURN
670 A1 = INT(A1): IF A1 >20 THEN A1 = 20
671 IF A1 <1 THEN A1 = 1
672 B$(Y,X) = LEFT$( LEFT$(T1$,A1) +" ",CW(X))
673 RETURN
675 OF = 1
680 IF X >XM THEN XM = X
681 IF Y >YM THEN YM = Y
690 RETURN
700 REM **** SUM(FUNCTION)
710 P = P +4: GOSUB 500
720 GOSUB 450:Y4 = Y3:X4 = X3
730 GOSUB 500: GOSUB 450
740 A1 = 0:A2 = 0:X5 = X3:Y5 = Y3
750 IF Y4 = Y5 THEN 800
760 X3 = X4: FOR Y3 = Y4 TO Y5
765 P = 1
770 GOSUB 480
780 NEXT Y3
790 GOSUB 600: RETURN
800 Y3 = Y4: FOR X3 = X4 TO X5
805 P = 1
810 GOSUB 480
820 NEXT X3
830 GOSUB 600: RETURN
900 REM * OUTPUT FORMAT *
905 GOSUB 200: GOSUB 500
910 IF C = 36 THEN OF = 1: GOTO 600
920 IF C = 73 THEN OF = 2: GOTO 600
930 IF C = 70 THEN OF = 3: GOTO 600
940 IF C = 42 THEN OF = 4: GOTO 600
950 GOTO 600
1000 REM ********************
1001 REM * VIDEO SCREEN LAYOUT
1002 REM ********************
1099 NORMAL
1100 FOR Y1 = 1 TO 70
1103 VTAB 1: HTAB 25: FLASH : PRINT "WORKING";
1105 IF Y1 >YM THEN Y1 = 100: GOTO 1180
1110 FOR X1 = 1 TO 10
1111 IF A$(Y1,X1) = "" THEN NEXT X1: GOTO 1180
1112 VTAB 1: HTAB 34: PRINT MID$ (T$,X1,1);Y1;" "
1115 IF X1 >XM THEN X1 = 100: GOTO 1170
1121 X2 = X:Y2 = Y
1122 X = X1:Y = Y1
1125 GOSUB 100
1140 X = X2:Y = Y2
1170 NEXT X1
1180 NEXT Y1
1185 GOSUB 1500
1186 VTAB 1: HTAB 25: CALL -868
1190 RETURN
1300 REM ********************
1301 REM * SCREEN VALUE PRINTER
1302 REM ********************
1305 CW(0) = 0
1306 IF CW(X) < > LEN(B$(Y,X)) THEN GOSUB 100
1307 IF X = SX THEN CO = 3: GOTO 1330
1310 CO = 0: FOR X2 = SX TO X -1:CO = CO +CW(X2): NEXT X2:CO = CO +3
1330 VTAB Y +5 -SY: HTAB CO
1340 PRINT B$(Y,X);
1399 RETURN
1500 REM *****************************
1501 REM *
1502 REM * SCREEN PRINT
1503 REM *
1504 REM *****************************
1550 VTAB 4: HTAB 1
1600 INVERSE
1602 PRINT " ";:MT = 10
1603 PP = 0: FOR FX = SX TO 10:PP = PP +CW(FX): IF PP >37 THEN MT = FX -1:FX = 11
1604 NEXT FX
1605 FOR FX = SX TO MT
1606 H = CW(FX)/2:H1 = INT(H):H2 = INT(H -.2)
1609 H$ = LEFT$(S$,H1) + MID$ (T$,FX,1) + LEFT$(S$,H2)
1610 PRINT H$;
1612 NEXT FX
1613 CALL -868
1614 VTAB 5: HTAB 1
1615 FOR FX = SY TO 18 +SY: PRINT FX;: IF FX <10 THEN PRINT " ";
1616 PRINT : NEXT FX
1617 VTAB 5
1618 NORMAL : POKE 32,2: POKE 33,38: VTAB 5: CALL -958: POKE 32,0: POKE 33,40
1619 A = SX:T = 3
1620 VTAB 5
1621 FOR X1 = 0 TO 18
1625 HTAB T: PRINT B$(SY +X1,A)
1800 NEXT X1
1850 T = T +CW(A):A = A +1: IF A = <MT THEN 1620
1999 RETURN
2000 REM **************
2001 REM *
2002 REM * PROMPT OF INPUT
2003 REM *
2004 REM **************
2005 DF = 1
2006 HOME
2010 GOSUB 1500
2020 X = 1:Y = 1
2030 VTAB 1: HTAB 1: PRINT MID$ (T$,X,1);Y;" "
2035 VTAB 2: HTAB 1: PRINT A$(Y,X);
2050 INVERSE
2060 GOSUB 1300
2070 NORMAL
2080 GOTO 2220
2090 REM ***************
2091 REM *
2092 REM * INPUT AND PERFORM
2093 REM *
2094 REM ***************
2100 A = PEEK( -16384): IF A <127 THEN 2100
2102 A = A -128:A$ = CHR$(A)
2103 IF A = 47 THEN 4000
2104 IF A = 64 THEN 2256
2105 IF A = 33 THEN GOSUB 1300: GOSUB 1000: GOTO 2050
2106 IF A = 21 THEN 2113
2107 IF A = 8 THEN 2160
2108 IF A = 32 THEN 2200
2109 IF A >43 THEN 2255
2110 IF A = 38 THEN 2300
2111 IF A = 34 THEN GET A$: GOTO 2255
2112 GET A$: GOTO 2090
2113 GOSUB 1300
2114 ON DF +2 GOTO 2115,2140,2130
2115 X = X +1: IF X >10 THEN X = 10: INVERSE : GOSUB 1300: NORMAL : GOTO 2900
2116 IF X >MT THEN SX = SX +1: GOSUB 1500: GOTO 2116
2120 INVERSE : GOSUB 1300: NORMAL : GOTO 2900
2130 Y = Y +1: IF Y >69 THEN Y = 69: GOTO 2135
2133 IF Y >18 +SY THEN X3 = -1:SY = SY +10:Y = SY +18: IF Y >69 THEN Y = 69:SY = 69 -18
2134 IF X3 = -1 THEN GOSUB 1500:X3 = 0
2135 INVERSE : GOSUB 1300: NORMAL
2140 GOTO 2900
2150 REM
2160 ON DF +2 GOTO 2170,2190,2180
2170 GOSUB 1300
2175 X = X -1: IF X > = SX THEN INVERSE : GOSUB 1300: NORMAL : GOTO 2900
2176 SX = SX -1: IF X = 0 THEN X = 1:SX = 1: GOTO 2179
2177 GOSUB 1500
2179 INVERSE : GOSUB 1300: NORMAL : GOTO 2900
2180 GOSUB 1300
2182 Y = Y -1: IF Y = >SY THEN INVERSE : GOSUB 1300: NORMAL : GOTO 2900
2183 SY = SY -10:Y = SY: IF Y < = 0 THEN Y = 1:SY = 1
2184 GOSUB 1500
2185 INVERSE : GOSUB 1300: NORMAL : GOTO 2900
2190 REM
2200 REM ********************
2201 REM *
2202 REM * SHOW CURSOR DIRECTION
2203 REM *
2204 REM ********************
2205 REM
2210 DF = DF * -1
2220 VTAB 1: HTAB 38
2230 ON DF +2 GOTO 2231,2240,2235
2231 PRINT "-";: GOTO 2240
2235 PRINT "!";: GOTO 2240
2240 GOTO 2900
2250 REM ** INPUT STRING FOR PAGE
2251 REM
2252 GOTO 4000
2254 IF A$ = "&" THEN 2300
2255 VTAB 2: HTAB 1: PRINT A$(Y,X);: VTAB 2: HTAB 1: GOSUB 220
2256 AA$ = " ": IF A$ = "@" THEN A$(Y,X) = LEFT$(AA$,CW(X)): GOTO 2260
2257 IF A$ = "" THEN 2270
2258 A$(Y,X) = A$
2260 GOSUB 100
2270 GOTO 2030
2300 REM ** SUM STATEMENT **
2310 POKE -16368,0
2320 VTAB 1: HTAB 1: CALL -868
2330 VTAB 2: INPUT "SUM(START = ";A$
2350 VTAB 2: CALL -868: PRINT "SUM(";A$;" THRU ";: INPUT "";B$
2360 VTAB 2: HTAB 1: PRINT "SUM(";A$;" THRU "B$;")"
2365 IF A$ = "" OR B$ = "" THEN 2900
2370 A$(Y,X) = "&SUM(" +A$ +"-" +B$ +")"
2380 GOSUB 100: GOTO 2030
2900 VTAB 1: HTAB 1: PRINT MID$ (T$,X,1);Y;" "
2904 VTAB 2: HTAB 1: PRINT A$(Y,X);
2905 CALL -868
2906 IF PEEK(37) = 1 THEN VTAB 3: HTAB 1: CALL -868
2907 POKE -16368,0
2910 GOTO 2100
4000 REM *****************
4001 REM *
4002 REM * HANDLE GLOBAL COMMAND
4003 REM *
4004 REM ******************
4005 POKE -16368,0
4006 VTAB 2: HTAB 1: CALL -868
4010 INPUT "1-WIDTH 2-SAVE 3-LOAD 4-CLEAR 5-GOTO LOCATION 6 - PRINT";A$
4015 ON VAL(A$) GOTO 4020,5000,5500,19,6000,7000
4016 GOTO 6000
4020 VTAB 2: CALL -868: INPUT "WIDTH = ";A$:A = VAL(A$): IF A >30 THEN 4020
4030 CW(X) = A
4040 YH = Y
4050 FOR Y = 1 TO YM: GOSUB 400: NEXT Y
4060 Y = YH
4140 GOSUB 1100
4150 GOSUB 5900: GOTO 2030
5000 REM ***********
5001 REM *
5002 REM * DISK I/O
5003 REM *
5004 REM ***********
5100 REM * FILE OUT *
5105 GOSUB 5900
5110 VTAB 2: HTAB 1: CALL -868
5120 PRINT "SAVE FILE TO DISK FILENAME = "
5130 INPUT "";A$
5140 IF A$ = "" THEN GOSUB 5900: GOTO 2030
5146 VTAB 1: HTAB 1: PRINT
5150 PRINT CHR$(4);"OPEN ";A$
5160 PRINT CHR$(4);"WRITE ";A$
5165 PRINT XM: PRINT YM
5170 FOR X = 1 TO XM
5180 PRINT CW(X)
5190 FOR Y = 1 TO YM
5200 PRINT CHR$(34);A$(Y,X); CHR$(34)
5210 NEXT Y
5220 PRINT "<>"
5230 NEXT X
5240 PRINT "<>"
5250 PRINT CHR$(4);"CLOSE"
5255 Y = 1:X = 1
5260 GOTO 7230
5500 REM * FILE IN *
5510 HOME : PRINT CHR$(4);"CATALOG"
5549 VTAB 1: HTAB 1
5550 PRINT "READ FILE FROM DISK FILENAME = "
5560 GOSUB 220: PRINT "": IF A$ = "" THEN GOSUB 5900: GOTO 2030
5565 PRINT CHR$(4);"UNLOCK";A$
5570 PRINT CHR$(4);"OPEN ";A$
5580 PRINT CHR$(4);"READ ";A$
5590 INPUT XM: INPUT YM
5600 FOR X = 1 TO XM
5610 INPUT CW(X)
5620 FOR Y = 1 TO YM
5630 INPUT A$(Y,X)
5640 NEXT Y
5650 INPUT B$: REM ERROR IF NOT <>
5660 NEXT X
5670 INPUT B$: REM ERROR IF NOT <>
5675 PRINT CHR$(4);"CLOSE"
5677 GOSUB 5900
5678 X = 1:Y = 1
5680 GOSUB 1000: GOTO 2020
5900 VTAB 1: HTAB 1: CALL -868
5910 VTAB 2: HTAB 1: CALL -868
5920 VTAB 3: HTAB 1: CALL -868
5930 RETURN
6000 REM ** GOTO LOCATION
6005 GOSUB 6010: GOTO 2030
6010 GOSUB 5900
6030 VTAB 2: HTAB 1: INPUT "GO TO PAGE LOCATION :";A$
6040 GOSUB 6200
6050 IF X1 +Y1 = 0 THEN RETURN
6180 X = X1:SX = X1:Y = Y1:SY = Y1
6185 GOSUB 1500
6190 INVERSE : GOSUB 1300: NORMAL : RETURN
6200 L = LEN(A$): IF L <2 THEN X1 = 0:Y1 = 0: RETURN
6210 X1 = ASC( LEFT$(A$,1)) -64
6220 IF X1 <1 OR X1 >10 THEN X1 = 0: RETURN
6230 Y1 = VAL( RIGHT$(A$,L -1))
6240 IF Y1 <1 OR Y1 >51 THEN X1 = 0:Y1 = 0
6250 RETURN
7000 REM *** PRINT OUT
7100 GOSUB 5900
7110 VTAB 2: HTAB 1: INPUT "UPPER/LEFT CORNER:";A$: GOSUB 6200
7120 X3 = X1:Y3 = Y1
7130 VTAB 2: HTAB 1: INPUT "LOWER/RIGHT CORNER :";A$: GOSUB 6200
7140 X4 = X1:Y4 = Y1
7150 PRINT CHR$(4);"PR#1"
7160 FOR Y1 = Y3 TO Y4
7170 FOR X1 = X3 TO X4
7180 PRINT LEFT$(B$(Y1,X1) +S$,CW(X1));
7190 NEXT X1
7200 PRINT
7210 NEXT Y1
7220 PRINT CHR$(4);"PR#0"
7230 X1 = 1:Y1 = 1: GOSUB 6180: GOTO 2030